package com.zy.yun.controller.app;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.yun.base.common.RestResult;
import com.zy.yun.base.entity.Organization;
import com.zy.yun.base.entity.Test01;
import com.zy.yun.base.entity.User;
import com.zy.yun.provider.service.ITest01Service;
import com.zy.yun.provider.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 王彦委
 * @since 2019-09-12
 */
@Api(description = "前端测试", tags = "前端测试管理")
@RestController
@RequestMapping("/test01")
public class Test01Controller {

    @Autowired
    private ITest01Service test01Service;

    @Autowired
    private IUserService userService;

    /**
     * @Author WangYanWei
     * @Description: 新增会员
     * @Date: 22:13 2019/10/16
     */
    @GetMapping("")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "password", value = "密码")
    })
    @ApiOperation(value = "新增会员", notes = "新增注册")
    public String test() {

        EntityWrapper<Test01> test01QueryWrapper = new EntityWrapper<>();
        test01QueryWrapper.eq("name", 11);
        Test01 one = test01Service.selectOne(test01QueryWrapper);

        System.out.println(one);
        return "ok";
    }

    @RequestMapping("userTest")
    public RestResult userTest() {

        EntityWrapper<User> userQueryWrapper = new EntityWrapper<>();

        userQueryWrapper.eq("u.name", "admin");
        userQueryWrapper.setSqlSelect("name");

        EntityWrapper<Organization> organizationQueryWrapper = new EntityWrapper<>();

        System.err.println(userQueryWrapper.getSqlSegment());
        System.err.println(userQueryWrapper.getSqlSelect());

        List<Map<String, Object>> maps1 = userService.maps(userQueryWrapper);
//        List<Map<String, Object>> maps = userService.listMaps(userQueryWrapper);


        return RestResult.buildSuccess(maps1);

    }


    public static void main(String[] args) {

    }
}
